//
//  HPPopTableCell.m
//  HPZZTong
//
//  Created by panbin on 13-11-26.
//  Copyright (c) 2013年 Handpay. All rights reserved.
//

#import "HPPopTableCell.h"
#import "ZZTongDefine.h"

@interface HPPopTableCell()

@property (nonatomic, retain) UIImageView *selectImageIcon;
@property (nonatomic, retain) UIImageView *imageIcon;
@property (nonatomic, retain) UILabel *iconName;

@end

@implementation HPPopTableCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        //self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _imageIcon = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.origin.x + 5, (self.bounds.size.height - 25)/2, 25, 25)];
        [self addSubview:_imageIcon];
        
        _iconName = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.origin.x + 35, _imageIcon.frame.origin.y, self.bounds.size.width - 50, 25)];
        _iconName.textColor = [UIColor blackColor];
        [_iconName setFont:[UIFont systemFontOfSize:13.0f]];
        [self  addSubview:_iconName];
        
        
        _selectImageIcon = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width - 70, (self.bounds.size.height - 22)/2, 22, 22)];
        [_selectImageIcon setImage:[UIImage imageNamed:@"select_row_icon"]];
        _selectImageIcon.hidden = YES;
        [self addSubview:_selectImageIcon];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
    
    if (selected) {
        _selectImageIcon.hidden = NO;
    }
    else {
        _selectImageIcon.hidden = YES;
    }
}

- (void)fillWithObject:(id)object {
    NSDictionary *model = (NSDictionary *)object;
    [_imageIcon setImage:[UIImage imageNamed:[model objectForKey:KEY_IMG_NAME]]];
    [_iconName setText:[model objectForKey:KEY_BANK_NAME]];
}

- (void)dealloc {
    HP_RELEASE(_imageIcon);
    HP_RELEASE(_iconName);
    HP_RELEASE(_selectImageIcon);
    [super dealloc];
}

@end
